package umlGui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JButton;

import umlTool.AccessModifiers;
import umlTool.ClassDiagram;
import umlTool.ClassField;
import umlTool.ClassMethod;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import umlTool.*;

public class mainWindow {

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					mainWindow window = new mainWindow();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public mainWindow() {
		initialize();
		
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e){
		}
		frame.setBounds(100, 100, 741, 441);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JMenuBar menuBar = new JMenuBar();
		frame.setJMenuBar(menuBar);

		JMenu mnNewMenu = new JMenu("File");
		menuBar.add(mnNewMenu);

		JMenuItem mntmExit = new JMenuItem("Exit");
		mntmExit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
			}
		});

		JMenuItem mntmNewProject = new JMenuItem("New Project");
		mnNewMenu.add(mntmNewProject);

		JMenuItem mntmSave = new JMenuItem("save");
		mnNewMenu.add(mntmSave);

		JMenuItem mntmExportToCode = new JMenuItem("export to code");
		mnNewMenu.add(mntmExportToCode);
		mnNewMenu.add(mntmExit);
		frame.getContentPane().setLayout(new BorderLayout(0, 0));

		JPanel panel = new JPanel();
		frame.getContentPane().add(panel, BorderLayout.WEST);
		panel.setLayout(new GridLayout(5, 0, 0, 25));

		final JPanel panel_2 = new JPanel();
		frame.getContentPane().add(panel_2, BorderLayout.CENTER);
		panel_2.setLayout(null);

		JLabel label = new JLabel("New label");
		label.setBounds(224, 111, 46, 14);
		panel_2.add(label);

		JButton btnNewButton_1 = new JButton("New button");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				// debug only DEBUGFLAG
				ClassDiagram c = new ClassDiagram();
				c.setName("debug");

				ClassMethod m = new ClassMethod();
				m.setName("n");
				m.setAccess(AccessModifiers.Private);
				m.setType("void");
				m.setStatic(true);
				m.setFinal(false);
				c.addMethod(m);
				ClassField f = new ClassField();
				f.setName("isOK");
				f.setType("Boolean");
				c.addField(f);
				c.createGetter(0);
				c.createSetter(0);
				classDiagramGui o = new classDiagramGui(c);
				o.putNames();
				o.setBounds(50, 50, 200, 200);
				panel_2.add(o);
				panel_2.repaint();
			}
		});
		panel.add(btnNewButton_1);

		JButton btnNewButton_2 = new JButton("New button");
		panel.add(btnNewButton_2);

		JButton btnNewButton = new JButton("New button");
		panel.add(btnNewButton);

		JPanel panel_1 = new JPanel();
		frame.getContentPane().add(panel_1, BorderLayout.EAST);
		panel_1.setLayout(new GridLayout(5, 0, 0, 0));

		JButton btnNewButton_3 = new JButton("New button");
		panel_1.add(btnNewButton_3);

	}
}
